'''
Pontifícia Universidade Católica do Paraná
Departamento de TI
Curso de Bigdata e inteligência analítica
Disciplina de análise exploratória de dados
Tutor Wellington R. Monteiro
Aluni Estevan Rafael Tomazini
'''
'\n\nPontifícia Universidade Católica do Paraná\nDepartamento de TI\nCurso de Bigdata e inteligência analítica\nDisciplina de análise exploratória de dados\nTutor Wellington R. Monteiro\nAluni Estevan Rafael Tomazini\n\n'
## Iniciaremos importando as bibliotecas utilizadas na ATP
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
# Atapa I da ATP: análise descritiva das variáveis disponíveis:
# 1º passo, leitura da base de dados, utilizando método read_CSV() da pandas.
df = pd.read_csv('/content/enron.csv')
df
| bonus | deferral_payments | deferred_income | director_fees | email_address | exercised_stock_options | expenses | from_messages | from_poi_to_this_person | from_this_person_to_poi | ... | other | poi | restricted_stock | restricted_stock_deferred | salary | shared_receipt_with_poi | to_messages | total_payments | total_stock_value | name | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 4175000.0 | 2869717.0 | -3081055.0 | NaN | phillip.allen@enron.com | 1729541.0 | 13868.0 | 2195.0 | 47.0 | 65.0 | ... | 152.0 | False | 126027.0 | -126027.0 | 201955.0 | 1407.0 | 2902.0 | 4484442.0 | 1729541.0 | ALLEN PHILLIP K |
| 1 | NaN | 178980.0 | NaN | NaN | NaN | 257817.0 | 3486.0 | NaN | NaN | NaN | ... | NaN | False | NaN | NaN | NaN | NaN | NaN | 182466.0 | 257817.0 | BADUM JAMES P |
| 2 | NaN | NaN | -5104.0 | NaN | james.bannantine@enron.com | 4046157.0 | 56301.0 | 29.0 | 39.0 | 0.0 | ... | 864523.0 | False | 1757552.0 | -560222.0 | 477.0 | 465.0 | 566.0 | 916197.0 | 5243487.0 | BANNANTINE JAMES M |
| 3 | 1200000.0 | 1295738.0 | -1386055.0 | NaN | NaN | 6680544.0 | 11200.0 | NaN | NaN | NaN | ... | 2660303.0 | False | 3942714.0 | NaN | 267102.0 | NaN | NaN | 5634343.0 | 10623258.0 | BAXTER JOHN C |
| 4 | 400000.0 | 260455.0 | -201641.0 | NaN | frank.bay@enron.com | NaN | 129142.0 | NaN | NaN | NaN | ... | 69.0 | False | 145796.0 | -82782.0 | 239671.0 | NaN | NaN | 827696.0 | 63014.0 | BAY FRANKLIN R |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 141 | NaN | NaN | -25000.0 | 108579.0 | NaN | NaN | 1413.0 | NaN | NaN | NaN | ... | NaN | False | NaN | NaN | NaN | NaN | NaN | 84992.0 | NaN | WINOKUR JR. HERBERT S |
| 142 | NaN | NaN | NaN | NaN | john.wodraska@enron.com | NaN | NaN | NaN | NaN | NaN | ... | 189583.0 | False | NaN | NaN | NaN | NaN | NaN | 189583.0 | NaN | WODRASKA JOHN |
| 143 | NaN | NaN | NaN | NaN | NaN | 139130.0 | NaN | NaN | NaN | NaN | ... | NaN | False | NaN | NaN | NaN | NaN | NaN | NaN | 139130.0 | WROBEL BRUCE |
| 144 | NaN | NaN | NaN | NaN | scott.yeager@enron.com | 8308552.0 | 53947.0 | NaN | NaN | NaN | ... | 147950.0 | True | 3576206.0 | NaN | 158403.0 | NaN | NaN | 360300.0 | 11884758.0 | YEAGER F SCOTT |
| 145 | NaN | NaN | NaN | NaN | NaN | 192758.0 | 55097.0 | NaN | NaN | NaN | ... | NaN | False | NaN | NaN | NaN | NaN | NaN | 55097.0 | 192758.0 | YEAP SOON |
146 rows × 22 columns
## temos 22 colunas, na próxima células serão verificados todos os nomes:
colunas = df.columns.tolist()
colunas
['bonus', 'deferral_payments', 'deferred_income', 'director_fees', 'email_address', 'exercised_stock_options', 'expenses', 'from_messages', 'from_poi_to_this_person', 'from_this_person_to_poi', 'loan_advances', 'long_term_incentive', 'other', 'poi', 'restricted_stock', 'restricted_stock_deferred', 'salary', 'shared_receipt_with_poi', 'to_messages', 'total_payments', 'total_stock_value', 'name']
'''
As colunas, a saber:
['bonus'] - Bônus
['deferral_payments'] - Pagamentos Diferidos -> pagamentos atrasados por negociação
['deferred_income'] - Renda Diferida
['director_fees'] - Taxas de Diretor
['email_address'] - Endereço de Email
['exercised_stock_options'] - Opções de Ações Exercidas
['expenses'] - Despesas
['from_messages'] - Mensagens Recebidas
['from_poi_to_this_person'] - De Pessoas de Interesse para Esta Pessoa
['from_this_person_to_poi'] - Desta Pessoa para Pessoas de Interesse
['loan_advances'] - Adiantamentos de Empréstimos
['long_term_incentive'] - Incentivo de Longo Prazo
['other'] - Outros
['poi'] - Pessoa de Interesse
['restricted_stock'] - Ações Restritas
['restricted_stock_deferred'] - Ações Restritas Diferidas
['salary'] - Salário
['shared_receipt_with_poi'] - Compartilhamento de Recibos com Pessoas de Interesse
['to_messages'] - Mensagens Enviadas
['total_payments'] - Pagamentos Totais
['total_stock_value'] - Valor Total das Ações
['name'] - Nome
'''
"\n\nAs colunas, a saber:\n\n['bonus'] - Bônus\n['deferral_payments'] - Pagamentos Diferidos -> pagamentos atrasados por negociação\n['deferred_income'] - Renda Diferida\n['director_fees'] - Taxas de Diretor\n['email_address'] - Endereço de Email\n['exercised_stock_options'] - Opções de Ações Exercidas\n['expenses'] - Despesas\n['from_messages'] - Mensagens Recebidas\n['from_poi_to_this_person'] - De Pessoas de Interesse para Esta Pessoa\n['from_this_person_to_poi'] - Desta Pessoa para Pessoas de Interesse\n['loan_advances'] - Adiantamentos de Empréstimos\n['long_term_incentive'] - Incentivo de Longo Prazo\n['other'] - Outros\n['poi'] - Pessoa de Interesse\n['restricted_stock'] - Ações Restritas\n['restricted_stock_deferred'] - Ações Restritas Diferidas\n['salary'] - Salário\n['shared_receipt_with_poi'] - Compartilhamento de Recibos com Pessoas de Interesse\n['to_messages'] - Mensagens Enviadas\n['total_payments'] - Pagamentos Totais\n['total_stock_value'] - Valor Total das Ações\n['name'] - Nome\n\n"
#Conversão da poi em valores 0 e 1
df['poi'] = df['poi'].map({False: 0, True: 1})
# from df
# where poi = 1;
# df2 onde poi == True dos 'person of interest', supostos fraudadores
df2 = df[df['poi'] == 1]
df.head()
| bonus | deferral_payments | deferred_income | director_fees | email_address | exercised_stock_options | expenses | from_messages | from_poi_to_this_person | from_this_person_to_poi | ... | other | poi | restricted_stock | restricted_stock_deferred | salary | shared_receipt_with_poi | to_messages | total_payments | total_stock_value | name | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 4175000.0 | 2869717.0 | -3081055.0 | NaN | phillip.allen@enron.com | 1729541.0 | 13868.0 | 2195.0 | 47.0 | 65.0 | ... | 152.0 | 0 | 126027.0 | -126027.0 | 201955.0 | 1407.0 | 2902.0 | 4484442.0 | 1729541.0 | ALLEN PHILLIP K |
| 1 | NaN | 178980.0 | NaN | NaN | NaN | 257817.0 | 3486.0 | NaN | NaN | NaN | ... | NaN | 0 | NaN | NaN | NaN | NaN | NaN | 182466.0 | 257817.0 | BADUM JAMES P |
| 2 | NaN | NaN | -5104.0 | NaN | james.bannantine@enron.com | 4046157.0 | 56301.0 | 29.0 | 39.0 | 0.0 | ... | 864523.0 | 0 | 1757552.0 | -560222.0 | 477.0 | 465.0 | 566.0 | 916197.0 | 5243487.0 | BANNANTINE JAMES M |
| 3 | 1200000.0 | 1295738.0 | -1386055.0 | NaN | NaN | 6680544.0 | 11200.0 | NaN | NaN | NaN | ... | 2660303.0 | 0 | 3942714.0 | NaN | 267102.0 | NaN | NaN | 5634343.0 | 10623258.0 | BAXTER JOHN C |
| 4 | 400000.0 | 260455.0 | -201641.0 | NaN | frank.bay@enron.com | NaN | 129142.0 | NaN | NaN | NaN | ... | 69.0 | 0 | 145796.0 | -82782.0 | 239671.0 | NaN | NaN | 827696.0 | 63014.0 | BAY FRANKLIN R |
5 rows × 22 columns
# Para as colunas com valores numéricos, o método describe() pode nos oferecer vários dados estatísticos
df.describe()
| bonus | deferral_payments | deferred_income | director_fees | exercised_stock_options | expenses | from_messages | from_poi_to_this_person | from_this_person_to_poi | loan_advances | long_term_incentive | other | poi | restricted_stock | restricted_stock_deferred | salary | shared_receipt_with_poi | to_messages | total_payments | total_stock_value | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count | 8.200000e+01 | 3.900000e+01 | 4.900000e+01 | 1.700000e+01 | 1.020000e+02 | 9.500000e+01 | 86.000000 | 86.000000 | 86.000000 | 4.000000e+00 | 6.600000e+01 | 9.300000e+01 | 146.000000 | 1.100000e+02 | 1.800000e+01 | 9.500000e+01 | 86.000000 | 86.000000 | 1.250000e+02 | 1.260000e+02 |
| mean | 2.374235e+06 | 1.642674e+06 | -1.140475e+06 | 1.668049e+05 | 5.987054e+06 | 1.087289e+05 | 608.790698 | 64.895349 | 41.232558 | 4.196250e+07 | 1.470361e+06 | 9.190650e+05 | 0.123288 | 2.321741e+06 | 1.664106e+05 | 5.621943e+05 | 1176.465116 | 2073.860465 | 5.081526e+06 | 6.773957e+06 |
| std | 1.071333e+07 | 5.161930e+06 | 4.025406e+06 | 3.198914e+05 | 3.106201e+07 | 5.335348e+05 | 1841.033949 | 86.979244 | 100.073111 | 4.708321e+07 | 5.942759e+06 | 4.589253e+06 | 0.329899 | 1.251828e+07 | 4.201494e+06 | 2.716369e+06 | 1178.317641 | 2582.700981 | 2.906172e+07 | 3.895777e+07 |
| min | 7.000000e+04 | -1.025000e+05 | -2.799289e+07 | 3.285000e+03 | 3.285000e+03 | 1.480000e+02 | 12.000000 | 0.000000 | 0.000000 | 4.000000e+05 | 6.922300e+04 | 2.000000e+00 | 0.000000 | -2.604490e+06 | -7.576788e+06 | 4.770000e+02 | 2.000000 | 57.000000 | 1.480000e+02 | -4.409300e+04 |
| 25% | 4.312500e+05 | 8.157300e+04 | -6.948620e+05 | 9.878400e+04 | 5.278862e+05 | 2.261400e+04 | 22.750000 | 10.000000 | 1.000000 | 1.600000e+06 | 2.812500e+05 | 1.215000e+03 | 0.000000 | 2.540180e+05 | -3.896218e+05 | 2.118160e+05 | 249.750000 | 541.250000 | 3.944750e+05 | 4.945102e+05 |
| 50% | 7.693750e+05 | 2.274490e+05 | -1.597920e+05 | 1.085790e+05 | 1.310814e+06 | 4.695000e+04 | 41.000000 | 35.000000 | 8.000000 | 4.176250e+07 | 4.420350e+05 | 5.238200e+04 | 0.000000 | 4.517400e+05 | -1.469750e+05 | 2.599960e+05 | 740.500000 | 1211.000000 | 1.101393e+06 | 1.102872e+06 |
| 75% | 1.200000e+06 | 1.002672e+06 | -3.834600e+04 | 1.137840e+05 | 2.547724e+06 | 7.995250e+04 | 145.500000 | 72.250000 | 24.750000 | 8.212500e+07 | 9.386720e+05 | 3.620960e+05 | 0.000000 | 1.002370e+06 | -7.500975e+04 | 3.121170e+05 | 1888.250000 | 2634.750000 | 2.093263e+06 | 2.949847e+06 |
| max | 9.734362e+07 | 3.208340e+07 | -8.330000e+02 | 1.398517e+06 | 3.117640e+08 | 5.235198e+06 | 14368.000000 | 528.000000 | 609.000000 | 8.392500e+07 | 4.852193e+07 | 4.266759e+07 | 1.000000 | 1.303223e+08 | 1.545629e+07 | 2.670423e+07 | 5521.000000 | 15149.000000 | 3.098866e+08 | 4.345095e+08 |
mediana = df.median()
mediana
<ipython-input-17-9813024f7b93>:1: FutureWarning: The default value of numeric_only in DataFrame.median is deprecated. In a future version, it will default to False. In addition, specifying 'numeric_only=None' is deprecated. Select only valid columns or specify the value of numeric_only to silence this warning. mediana = df.median()
bonus 769375.0 deferral_payments 227449.0 deferred_income -159792.0 director_fees 108579.0 exercised_stock_options 1310813.5 expenses 46950.0 from_messages 41.0 from_poi_to_this_person 35.0 from_this_person_to_poi 8.0 loan_advances 41762500.0 long_term_incentive 442035.0 other 52382.0 poi 0.0 restricted_stock 451740.0 restricted_stock_deferred -146975.0 salary 259996.0 shared_receipt_with_poi 740.5 to_messages 1211.0 total_payments 1101393.0 total_stock_value 1102872.5 dtype: float64
'''
Nessa primeira análise descritiva podemos verificar a contagem dos elementos por coluna,
a média, mediana, desvio padrão, valores de mínimo, máximo e os 1º, 2º e 3º quartis.
Uma caracteristica que chama a atenção são os valores faltantes por coluna, dos 146
valores de entrada apenas as colunas nome e poi estão completas, sendo que
loan_advances conta com apenas 4 valores, dessa forma os valores 'NaN' podem dificultar
as análises
A seguir será mostrado o método info() para facilitar a visualização do total de
colunas, valores faltantes e quais são numéricas.
'''
"\nNessa primeira análise descritiva podemos verificar a contagem dos elementos por coluna,\na média, mediana, desvio padrão, valores de mínimo, máximo e os 1º, 2º e 3º quartis.\n\nUma caracteristica que chama a atenção são os valores faltantes por coluna, dos 146 \nvalores de entrada apenas as colunas nome e poi estão completas, sendo que \nloan_advances conta com apenas 4 valores, dessa forma os valores 'NaN' podem dificultar \nas análises \n\nA seguir será mostrado o método info() para facilitar a visualização do total de\ncolunas, valores faltantes e quais são numéricas.\n"
df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 146 entries, 0 to 145 Data columns (total 22 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 bonus 82 non-null float64 1 deferral_payments 39 non-null float64 2 deferred_income 49 non-null float64 3 director_fees 17 non-null float64 4 email_address 111 non-null object 5 exercised_stock_options 102 non-null float64 6 expenses 95 non-null float64 7 from_messages 86 non-null float64 8 from_poi_to_this_person 86 non-null float64 9 from_this_person_to_poi 86 non-null float64 10 loan_advances 4 non-null float64 11 long_term_incentive 66 non-null float64 12 other 93 non-null float64 13 poi 146 non-null int64 14 restricted_stock 110 non-null float64 15 restricted_stock_deferred 18 non-null float64 16 salary 95 non-null float64 17 shared_receipt_with_poi 86 non-null float64 18 to_messages 86 non-null float64 19 total_payments 125 non-null float64 20 total_stock_value 126 non-null float64 21 name 146 non-null object dtypes: float64(19), int64(1), object(2) memory usage: 25.2+ KB
# aplicaremos o método corr() para verificar as correlações entre as colunas fornecidas nessa planilha
df.corr()
<ipython-input-20-d49ebe83b06e>:2: FutureWarning: The default value of numeric_only in DataFrame.corr is deprecated. In a future version, it will default to False. Select only valid columns or specify the value of numeric_only to silence this warning. df.corr()
| bonus | deferral_payments | deferred_income | director_fees | exercised_stock_options | expenses | from_messages | from_poi_to_this_person | from_this_person_to_poi | loan_advances | long_term_incentive | other | poi | restricted_stock | restricted_stock_deferred | salary | shared_receipt_with_poi | to_messages | total_payments | total_stock_value | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| bonus | 1.000000 | 0.978808 | -0.980138 | NaN | 0.990518 | 0.989117 | 0.052725 | 0.562187 | 0.354634 | 0.640266 | 0.995012 | 0.961757 | -0.013837 | 0.985062 | -0.975080 | 0.993425 | 0.549102 | 0.372997 | 0.963154 | 0.990202 |
| deferral_payments | 0.978808 | 1.000000 | -0.994974 | 1.000000 | 0.960891 | 0.973234 | 0.321947 | 0.424101 | 0.206993 | 0.356130 | 0.971950 | 0.958584 | -0.084502 | 0.970340 | -0.996176 | 0.977846 | 0.356696 | 0.310129 | 0.923344 | 0.963424 |
| deferred_income | -0.980138 | -0.994974 | 1.000000 | -0.995729 | -0.977234 | -0.970539 | -0.319995 | -0.178951 | -0.271673 | -0.433300 | -0.982358 | -0.945725 | 0.014201 | -0.971404 | 0.973253 | -0.977737 | -0.394677 | -0.350815 | -0.925775 | -0.975203 |
| director_fees | NaN | 1.000000 | -0.995729 | 1.000000 | 0.996597 | 0.995207 | 1.000000 | NaN | 1.000000 | NaN | NaN | 1.000000 | NaN | 0.999011 | -0.565314 | NaN | 1.000000 | -1.000000 | 0.994356 | 0.997112 |
| exercised_stock_options | 0.990518 | 0.960891 | -0.977234 | 0.996597 | 1.000000 | 0.983227 | -0.066129 | 0.160253 | -0.030101 | 0.665824 | 0.990516 | 0.967541 | 0.052886 | 0.991501 | -0.475566 | 0.992739 | 0.154333 | 0.079568 | 0.965020 | 0.998869 |
| expenses | 0.989117 | 0.973234 | -0.970539 | 0.995207 | 0.983227 | 1.000000 | 0.094144 | -0.059244 | 0.014964 | 0.600193 | 0.988083 | 0.953230 | -0.044508 | 0.982824 | -0.976320 | 0.995945 | 0.223495 | 0.155070 | 0.946242 | 0.984372 |
| from_messages | 0.052725 | 0.321947 | -0.319995 | 1.000000 | -0.066129 | 0.094144 | 1.000000 | 0.186708 | 0.588687 | -0.213768 | -0.071958 | -0.101686 | -0.074308 | 0.003145 | -0.326671 | -0.003541 | 0.230855 | 0.475450 | -0.033089 | -0.036310 |
| from_poi_to_this_person | 0.562187 | 0.424101 | -0.178951 | NaN | 0.160253 | -0.059244 | 0.186708 | 1.000000 | 0.445063 | 0.009878 | 0.212538 | 0.111249 | 0.167722 | 0.133594 | -0.455876 | 0.179055 | 0.659264 | 0.525667 | 0.154431 | 0.146366 |
| from_this_person_to_poi | 0.354634 | 0.206993 | -0.271673 | 1.000000 | -0.030101 | 0.014964 | 0.588687 | 0.445063 | 1.000000 | 0.934835 | 0.083591 | -0.110335 | 0.112940 | 0.049284 | -0.398550 | 0.021288 | 0.475748 | 0.568506 | 0.011556 | 0.001289 |
| loan_advances | 0.640266 | 0.356130 | -0.433300 | NaN | 0.665824 | 0.600193 | -0.213768 | 0.009878 | 0.934835 | 1.000000 | 0.553638 | 0.584598 | 0.560178 | 0.585069 | NaN | 0.600576 | 0.291501 | 0.739805 | 0.816098 | 0.667922 |
| long_term_incentive | 0.995012 | 0.971950 | -0.982358 | NaN | 0.990516 | 0.988083 | -0.071958 | 0.212538 | 0.083591 | 0.553638 | 1.000000 | 0.967764 | -0.021222 | 0.994575 | -0.977703 | 0.991984 | 0.178944 | 0.134277 | 0.961361 | 0.990130 |
| other | 0.961757 | 0.958584 | -0.945725 | 1.000000 | 0.967541 | 0.953230 | -0.101686 | 0.111249 | -0.110335 | 0.584598 | 0.967764 | 1.000000 | -0.012457 | 0.973823 | -0.480336 | 0.963194 | 0.122591 | 0.040580 | 0.982724 | 0.971644 |
| poi | -0.013837 | -0.084502 | 0.014201 | NaN | 0.052886 | -0.044508 | -0.074308 | 0.167722 | 0.112940 | 0.560178 | -0.021222 | -0.012457 | 1.000000 | -0.000107 | NaN | -0.030884 | 0.228313 | 0.058954 | 0.040130 | 0.025163 |
| restricted_stock | 0.985062 | 0.970340 | -0.971404 | 0.999011 | 0.991501 | 0.982824 | 0.003145 | 0.133594 | 0.049284 | 0.585069 | 0.994575 | 0.973823 | -0.000107 | 1.000000 | -0.483150 | 0.988797 | 0.232660 | 0.195570 | 0.965482 | 0.995813 |
| restricted_stock_deferred | -0.975080 | -0.996176 | 0.973253 | -0.565314 | -0.475566 | -0.976320 | -0.326671 | -0.455876 | -0.398550 | NaN | -0.977703 | -0.480336 | NaN | -0.483150 | 1.000000 | -0.978801 | -0.348405 | -0.359420 | -0.429481 | -0.977301 |
| salary | 0.993425 | 0.977846 | -0.977737 | NaN | 0.992739 | 0.995945 | -0.003541 | 0.179055 | 0.021288 | 0.600576 | 0.991984 | 0.963194 | -0.030884 | 0.988797 | -0.978801 | 1.000000 | 0.284995 | 0.187047 | 0.957060 | 0.992490 |
| shared_receipt_with_poi | 0.549102 | 0.356696 | -0.394677 | 1.000000 | 0.154333 | 0.223495 | 0.230855 | 0.659264 | 0.475748 | 0.291501 | 0.178944 | 0.122591 | 0.228313 | 0.232660 | -0.348405 | 0.284995 | 1.000000 | 0.847990 | 0.191069 | 0.176314 |
| to_messages | 0.372997 | 0.310129 | -0.350815 | -1.000000 | 0.079568 | 0.155070 | 0.475450 | 0.525667 | 0.568506 | 0.739805 | 0.134277 | 0.040580 | 0.058954 | 0.195570 | -0.359420 | 0.187047 | 0.847990 | 1.000000 | 0.133834 | 0.120864 |
| total_payments | 0.963154 | 0.923344 | -0.925775 | 0.994356 | 0.965020 | 0.946242 | -0.033089 | 0.154431 | 0.011556 | 0.816098 | 0.961361 | 0.982724 | 0.040130 | 0.965482 | -0.429481 | 0.957060 | 0.191069 | 0.133834 | 1.000000 | 0.969242 |
| total_stock_value | 0.990202 | 0.963424 | -0.975203 | 0.997112 | 0.998869 | 0.984372 | -0.036310 | 0.146366 | 0.001289 | 0.667922 | 0.990130 | 0.971644 | 0.025163 | 0.995813 | -0.977301 | 0.992490 | 0.176314 | 0.120864 | 0.969242 | 1.000000 |
'''
Aqui podemos ter uma noção sobre o relacionamento entre essas variáveis,
onde valores proximos de +1 apresentam forte correlação positiva e
valores próximos a -1 mostram forte correlação negativa.
Quanto mais próximos de 0, menor a correlação.
Chamo a atenção as correlações com o 'poi', que serão utilizadas a frente
todos os valores contam com baixa correlação, com os maiores valores sendo
loan_advances (0,56), share_receipt_with_poi (0,23) e from_poi_to_this_person (0,16)
Porém esses valores são os mais elevados devido aos varios valores faltantes.
também director_fee = NaN
'''
'\nAqui podemos ter uma noção sobre o relacionamento entre essas variáveis, \nonde valores proximos de +1 apresentam forte correlação positiva e \nvalores próximos a -1 mostram forte correlação negativa.\nQuanto mais próximos de 0, menor a correlação.\n\nChamo a atenção as correlações com o poi, que serão utilizadas a frente\ntodos os valores contam com baixa correlação, com os maiores valores sendo\nloan_advances (0,56), share_receipt_with_poi (0,23) e from_poi_to_this_person (0,16)\ntambém director_fee = NaN\n'
df.nunique()
bonus 41 deferral_payments 39 deferred_income 44 director_fees 17 email_address 111 exercised_stock_options 101 expenses 94 from_messages 64 from_poi_to_this_person 57 from_this_person_to_poi 41 loan_advances 4 long_term_incentive 52 other 92 poi 2 restricted_stock 97 restricted_stock_deferred 18 salary 94 shared_receipt_with_poi 83 to_messages 86 total_payments 125 total_stock_value 124 name 146 dtype: int64
# soma de todos os valores nulos para as colunas
df.isnull().sum()
bonus 64 deferral_payments 107 deferred_income 97 director_fees 129 email_address 35 exercised_stock_options 44 expenses 51 from_messages 60 from_poi_to_this_person 60 from_this_person_to_poi 60 loan_advances 142 long_term_incentive 80 other 53 poi 0 restricted_stock 36 restricted_stock_deferred 128 salary 51 shared_receipt_with_poi 60 to_messages 60 total_payments 21 total_stock_value 20 name 0 dtype: int64
df.poi.sum()
18
## 18 supostos fraudadores
'''
Parte II: Analises univariadas
'''
'\n\nParte II: Analises univariadas\n\n'
coluna = 'bonus'
# Cria boxplot
sns.boxplot(x=coluna, data=df) #showfliers=False para retirar whiskers
#sns.boxplot(x=coluna, data=df)
## o parametro showfliers foi utilizado para ignorar os outliers em casos onde não
## é possível verificar o gráfico. Porém não sei se é a intenção da atividade
# titulos e outros modificadores
plt.title('Boxplot da variável {}'.format(coluna))
plt.xlabel(coluna)
# mostra plot
plt.show()
## Os histogramas seguem o mesmo principio, dessa forma não serão comentados
coluna = 'bonus'
# cria histograma
sns.histplot(x=coluna, data=df)
plt.title('Histograma da variável {}'.format(coluna))
plt.xlabel(coluna)
plt.ylabel('Frequencia')
plt.show()
coluna = 'deferral_payments'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'deferral_payments'
sns.histplot(x=coluna, data=df)
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.ylabel('Frequencia')
plt.show()
coluna = 'deferred_income'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'deferred_income'
sns.histplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.ylabel('Frequencia')
plt.show()
coluna = 'director_fees'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'director_fees'
sns.histplot(x=coluna, data=df)
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.ylabel('Frequncia')
plt.show()
'''
e-mail não é numerico e não faz sentido mostrar frequencia
'''
'\n\ne-mail não é numerico e não faz sentido mostrar frequencia\n\n'
coluna = 'exercised_stock_options'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'exercised_stock_options'
sns.histplot(x=coluna, data=df, bins=30)
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.ylabel('Frequencia')
plt.show()
coluna = 'expenses'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot of {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'expenses'
sns.histplot(x=coluna, data=df, bins=50)
# limites ajustados para gráfico visualmente mais agradável
plt.title('histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.ylabel("Frequencia")
plt.xlim(0, 6000000)
plt.show()
coluna = 'from_messages'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'from_messages'
sns.histplot(x=coluna, data=df, bins=50)
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.ylabel("Frequência")
plt.xlim(0, 8000)
## Limitei eixo x para facilitar a visualização
# mostrar
plt.show()
coluna = 'from_poi_to_this_person'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'from_poi_to_this_person'
sns.histplot(x=coluna, data=df)
plt.title('histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.ylabel('Frequencia')
plt.show()
coluna = 'from_this_person_to_poi'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'from_this_person_to_poi'
sns.histplot(x=coluna, data=df)
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.ylabel("Frequência")
plt.show()
coluna = 'loan_advances'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'loan_advances'
sns.histplot(x=coluna, data=df)
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'long_term_incentive'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'long_term_incentive'
sns.histplot(x=coluna, data=df, bins=50)
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.ylabel("Frequencia")
plt.xlim(0, 50000000)
plt.show()
coluna = 'other'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'other'
sns.histplot(x=coluna, data=df, bins=80)
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.xlim(0, 8000000)
plt.show()
coluna = 'poi'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'poi'
sns.histplot(x=coluna, data=df)
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'restricted_stock'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'restricted_stock'
sns.histplot(x=coluna, data=df, bins=50)
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.ylabel("Frequencia")
plt.xlim(0, 100000000)
plt.show()
coluna = 'restricted_stock_deferred'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'restricted_stock'
# Create a boxplot
sns.histplot(x=coluna, data=df, bins=50)
# Set the plot title and labels
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.ylabel("Frequencia")
#plt.xlim(-10000000, 50000000)
# Show the plot
plt.show()
coluna = 'salary'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'salary'
sns.histplot(x=coluna, data=df)
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.xlim(0, 2000000)
plt.show()
coluna = 'shared_receipt_with_poi'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'shared_receipt_with_poi'
sns.histplot(x=coluna, data=df)
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'to_messages'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'to_messages'
sns.histplot(x=coluna, data=df)
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'total_payments'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'total_payments'
sns.histplot(x=coluna, data=df)
plt.title('histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.xlim(0, 10000000)
plt.show()
coluna = 'total_stock_value'
sns.boxplot(x=coluna, data=df)
plt.title('Boxplot de {}'.format(coluna))
plt.xlabel(coluna)
plt.show()
coluna = 'total_stock_value'
sns.histplot(x=coluna, data=df)
plt.title('Histograma de {}'.format(coluna))
plt.xlabel(coluna)
plt.xlim(0, 60000000)
plt.show()
# Nome não é numerica
'''
Parte III: analises multivariadas:
Considerando os dados obtidos nas analises de correlação mostrados na parte I
dessa ATP, aqui serão mostradas as analises multivariadas,
principalmente os pairplots com os valores poi diferenciados
'''
'\nParte III: analises multivariadas:\n\nConsiderando os dados obtidos nas analises de correlação mostrados na parte I\ndessa ATP, aqui serão mostradas as analises multivariadas,\nprincipalmente os pairplots com os valores poi diferenciados\n\n'
#colunas para o pairplot
colunas = ['salary', 'bonus', 'total_payments', 'total_stock_value', 'poi']
# pairplot com hue = poi
sns.pairplot(data=df[colunas], hue='poi')
# plot
plt.show()
## Aqui os valores em amarelo são os possíveis fraudadores, POI - person of interest.
## eles serão mostrados em todos os pairplots que servirão de base para a finalização da ATP
## entre os valores mais importantes verficados nessas variáveis, temos:
## valor total em ações
## Bônus
## pagamentos
## as variáveis se mostraram as mais relevantes
#colunas para o pairplot
colunas = ['poi', 'shared_receipt_with_poi', 'to_messages','total_payments','total_stock_value']
# poi como hue
sns.pairplot(data=df[colunas], hue='poi')
# plot
plt.show()
#colunas para o pairplot
colunas = ['poi', 'from_this_person_to_poi','loan_advances','long_term_incentive', 'other','restricted_stock','restricted_stock_deferred']
# poi como hue
sns.pairplot(data=df[colunas], hue='poi')
# plot
plt.show()
#colunas para o pairplot
colunas = ['poi', 'shared_receipt_with_poi', 'to_messages','total_payments','total_stock_value']
# poi como hue
sns.pairplot(data=df[colunas], hue='poi')
# plot
plt.show()
#colunas para o pairplot
colunas = ['bonus', 'deferral_payments','deferred_income', 'director_fees', 'poi']
# poi como hue
sns.pairplot(data=df[colunas], hue='poi')
# plot
plt.show()
#colunas para o pairplot
colunas = ['bonus', 'deferral_payments','deferred_income', 'director_fees', 'poi']
# poi como hue
sns.pairplot(data=df[colunas], hue='poi')
# plot
plt.show()
## nesse caso é possível verificar que aqueles processos que passaram pela diretoria, não contém possíveis fraudadores
#colunas para o pairplot
colunas = ['shared_receipt_with_poi', 'to_messages','total_payments','total_stock_value', 'poi']
# poi como hue
sns.pairplot(data=df[colunas], hue='poi')
# plot
plt.show()
#colunas para o pairplot
colunas = ['other','restricted_stock','restricted_stock_deferred','salary','poi']
# poi como hue
sns.pairplot(data=df[colunas], hue='poi')
# plot
plt.show()
#colunas para o pairplot
colunas = ['exercised_stock_options','from_this_person_to_poi','loan_advances','long_term_incentive','poi']
# poi como hue
sns.pairplot(data=df[colunas], hue='poi')
# plot
plt.show()
## Opções exercidas com valores elevados recebem mensagem de determinada pessoa, fraudadores
#colunas para o pairplot
colunas = ['expenses','from_messages','from_poi_to_this_person','poi']
# poi como hue
sns.pairplot(data=df[colunas], hue='poi')
# plot
plt.show()
'''
Pairplot com realce dos 'poi' nos permite verificar padrões, quais variáveis
podem expôr os 'poi' em dada condição.
Entre as mais promissoras temos:
bônus em relação ao salário
ações exercidas em relação ao salário
mensagem de 'poi'
Próxima tentativa será verificar correlações via heatmap
''
## esboço 1 com todas as colunas:
columns_to_analyze = ['bonus', 'deferral_payments','deferred_income',
'director_fees','exercised_stock_options',
'expenses','from_messages','from_poi_to_this_person',
'from_this_person_to_poi','loan_advances','long_term_incentive',
'other','poi','restricted_stock','restricted_stock_deferred','salary',
'shared_receipt_with_poi', 'to_messages','total_payments','total_stock_value']
# calcular matriz de correlação
corr_matrix = df[columns_to_analyze].corr()
# criar o heatmap
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm')
# titulo
plt.title('Matriz de correlação')
# mostrar
plt.show()
# to do list
#['bonus', 'deferral_payments','deferred_income',
# 'director_fees','email_address','exercised_stock_options',
# 'expenses','from_messages','from_poi_to_this_person',
# 'from_this_person_to_poi','loan_advances','long_term_incentive',
# 'other','poi','restricted_stock','restricted_stock_deferred','salary',
# 'shared_receipt_with_poi', 'to_messages','total_payments','total_stock_value','name']
## primeira leva
columns_to_analyze = ['exercised_stock_options', 'expenses','from_messages','from_poi_to_this_person', 'poi']
corr_matrix = df[columns_to_analyze].corr()
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm')
plt.title('Correlation Matrix')
plt.show()
## como é possível analisar mais variáveis sem poluir muito o gráfico:
columns_to_analyze = ['poi', 'bonus', 'deferral_payments','deferred_income', 'director_fees','exercised_stock_options', 'expenses','from_messages','from_poi_to_this_person']
corr_matrix = df[columns_to_analyze].corr()
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm')
plt.title('Matriz de correlação')
plt.show()
## terceira
columns_to_analyze = ['poi', 'from_this_person_to_poi','loan_advances','long_term_incentive', 'other','restricted_stock','restricted_stock_deferred','salary']
corr_matrix = df[columns_to_analyze].corr()
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm')
plt.title('Matriz de correlação')
plt.show()
# Aquelas com maior correlação com 'poi' apenas para visualização facilitada
columns_to_analyze = ['poi', 'shared_receipt_with_poi', 'to_messages','total_payments','total_stock_value']
corr_matrix = df[columns_to_analyze].corr()
sns.heatmap(corr_matrix, annot=True, cmap='coolwarm')
plt.title('Matriz de correlação')
plt.show()
'''
Esses heatmaps reforçam a ideia de que 'poi' não poderá ser solucionado com
sua correlação direta.
Agora serão feitas algumas tentativas de clarificar as relações
'''
# Primeira tentativa de análise via scatterplot, dispersão.
# Colunas em analise
coluna_x = 'salary'
coluna_y = 'bonus'
# scatter plot
sns.scatterplot(data=df, x=coluna_x, y=coluna_y)
# caracteristicas secundárias
plt.title('Scatter Plot de Salário vs Bônus')
plt.xlabel(coluna_x)
plt.ylabel(coluna_y)
plt.xlim(0,40000000)
# mostrar plot
plt.show()
# correlação de 0,9934
## Aqui percebi que seria necessário excluir alguns outliers da visualização para
## de fato visualizar alguma relação
## principalmente o maior bonus/salário/detentor de ações, que não é 'poi'
# Uma regressão.
coluna_x = 'salary'
coluna_y = 'bonus'
# Cria regressão
sns.regplot(data=df, x=coluna_x, y=coluna_y)
# Parametros adicionais
plt.title('Regressão de Salario x bônus')
plt.xlabel(coluna_x)
plt.ylabel(coluna_y)
plt.xlim(0, 1000000)
plt.ylim(0, 10000000)
# Mostrar
plt.show()
## Nesse ponto vi que seria necessário dividir os 2 valores separadamente
# regressão de bonus vs salário
x_coluna = 'salary'
y_coluna = 'bonus'
# Séries analisadas com cores diferentes
sns.regplot(data=df, x=x_coluna, y=y_coluna, color='red', label=x_coluna)
sns.regplot(data=df, x=y_coluna, y=y_coluna, color='blue', label=y_coluna)
# titulo e eixos
plt.title('Scatter Plot de {} vs {}'.format(x_coluna, y_coluna))
plt.xlabel(x_coluna)
plt.ylabel(y_coluna)
# legenda
plt.legend()
# plot
plt.show()
## Aqui verifiquei o caráter linear do bônus,
## antes de buscar alguma forma adicionar os 'poi',
## decidi limitar os valores dos eixos para melhorar a visualização
# regressão de bonus vs salário
x_coluna = 'salary'
y_coluna = 'bonus'
# Séries analisadas com cores diferentes
sns.regplot(data=df, x=x_coluna, y=y_coluna, color='red', label=x_coluna)
sns.regplot(data=df, x=y_coluna, y=y_coluna, color='blue', label=y_coluna)
# titulo e eixos
plt.title('Scatter Plot de {} vs {}'.format(x_coluna, y_coluna))
plt.xlabel(x_coluna)
plt.ylabel(y_coluna)
plt.xlim(0, 10000000)
plt.ylim(0, 20000000)
# legenda
plt.legend()
# plot
plt.show()
## Nesse ponto que percebi que seria necessário utilizar o parametro 'hue'
## em uma analise que seguia a lógica em SQL
## from coluna where 'poi' ==1;
## nesse ponto que apliquei a transformação de 0 e 1 na entidade 'poi'
## Bõnus é puramente linear
## tentativa de separar as populações
coluna_x = 'salary'
coluna_y = 'bonus'
coluna_hue = 'poi'
# criar scatterplot com mais variáveis
sns.scatterplot(data=df, x=coluna_x, y=coluna_y, hue=coluna_hue, color='r')
sns.scatterplot(data=df, x=coluna_y, y=coluna_y, hue=coluna_hue, color='b')
# detalhes do plot
plt.title('Scatter Plot de bonus em função do salário')
plt.xlim(0, 5000000)
plt.ylim(0, 50000000)
# mostrar
plt.show()
## Nesse ponto começamos a perceber os detalhes
## Aqui foi o ponto onde decidi realizar o screening de todas as variáveis através
## do pairplot realizado anteriormente.
coluna_x = 'salary'
coluna_y = 'bonus'
coluna_hue = 'poi'
# Create a scatter plot with different colors for each category
sns.scatterplot(data=df, x=coluna_x, y=coluna_y, hue=coluna_hue, color='r')
#sns.scatterplot(data=df, x=coluna_y, y=coluna_y, hue=coluna_hue, color='b', label='Bonus')
# detalhes do plot
plt.title('Scatter Plot de bonus em função do salário')
plt.xlim(0, 800000)
plt.ylim(0, 5000000)
# mostrar
plt.show()
'''
Todos os 'poi' ocorrem com salarios acima de 200 mil ao ano.
'''
## Pessoas com ações restritas deferidas não contém nenhum
## possível fraudador
## Valor total em ações correlaciona fortemente com possíveis fraudadores
## Podemos abservar que onde foi pago director's fee, não existem possíveis fraudadores
## Para ações restritas deferidas não contem possíveis fraudadores
## As variáveis onde se observam os possíveis fraudadores são bônus, pagamentos e grandes quantidades de ações
coluna_x = 'shared_receipt_with_poi'
coluna_hue = 'poi'
# cria scatterplot
sns.scatterplot(data=df, x=coluna_x, y=coluna_y, hue=coluna_hue, color='r')
#sns.scatterplot(data=df, x=coluna_y, y=coluna_y, hue=coluna_hue, color='b', label='Bonus')
# detalhes do plot
plt.title('Scatter Plot de poi nos recibos')
plt.xlim(0, 6000)
plt.ylim()
# mostrar
plt.show()
'''
Pessoas que compartilharam mais de 2500 notas com um 'poi' tem chance mínima de
ser 'poi', com excessão de 1 outlier
Pessoas que receberam mais de 5 milhões em bonûs, são provavelmente 'poi', com
excessão do maior valor, outro outlier
'''
'\n\n'
coluna_x = 'to_messages'
coluna_hue = 'poi'
sns.scatterplot(data=df, x=coluna_x, y=coluna_y, hue=coluna_hue, color='r')
#sns.scatterplot(data=df, x=coluna_y, y=coluna_y, hue=coluna_hue, color='b', label='Bonus')
# detalhes do plot
plt.title('Scatter Plot de poi em mensagens enviadas')
plt.xlim(0, 16000)
plt.ylim()
# mostrar
plt.show()
'''
Pessoas que recebera, mais de 5000 mensagens dificilmente são 'poi'.
Maior concentração de pessoas 'poi' está entre 1000 e 5000 mensagens recebidas
'''
'\n\nPessoas que recebera, mais de 4500 mensagens \n\n'
## Bônus acima de 5 milhões é grande indicativo de fraude
coluna_y = 'bonus'
coluna_x = 'total_payments'
coluna_hue = 'poi'
# Criar scatterplot
sns.scatterplot(data=df, x=coluna_x, y=coluna_y, hue=coluna_hue, color='r')
#sns.scatterplot(data=df, x=coluna_y, y=coluna_y, hue=coluna_hue, color='b', label='Bonus')
# detalhes do plot
plt.title('Scatter Plot de poi no total pago')
plt.xlim(0, 10000000)
plt.ylim(0, 6000000)
# mostrar
plt.show()
'''
uma relação bônus/Total pago elevada aumenta muito
a probabilidade de pessoa 'poi'
'''
## É possível observar que onde o bônus é superior a 5 milhões, temos 100 % de possíveis fraudadores
## Quando o bônus é maior do que salário, temos possíveis fraudadores
## Bônus muito elevado em relação ao salário tem alta correlação com possíveis fraudadores
coluna_x = 'total_stock_value'
coluna_y = 'salary'
coluna_hue = 'poi'
sns.scatterplot(data=df, x=coluna_x, y=coluna_y, hue=coluna_hue, color='r')
#sns.scatterplot(data=df, x=coluna_y, y=coluna_y, hue=coluna_hue, color='b', label='Bonus')
# detalhes do plot
plt.title('Scatter Plot de poi no total em ações')
plt.xlim(0, 10000000)
plt.ylim(0, 1000000)
# mostrar
plt.show()
'''
Todos os 'poi' recebem salário acima de 200 mil ao ano
'''
coluna_x = 'total_stock_value'
coluna_y = 'salary'
coluna_hue = 'poi'
# Create a scatter plot with different colors for each category
sns.scatterplot(data=df, x=coluna_x, y=coluna_y, hue=coluna_hue, color='r')
#sns.scatterplot(data=df, x=coluna_y, y=coluna_y, hue=coluna_hue, color='b', label='Bonus')
# detalhes do plot
plt.title('Scatter Plot de poi no total em ações')
plt.xlim(0, 60000000)
plt.ylim(0, 2000000)
# mostrar
plt.show()
'''
Pessoas com valor total em ações acima de 20 milhões tem grande possibilidade
de serem 'poi'
'''
"\n\nPessoas com valor total em ações acima de 20 milhões tem grande possibilidade\nde serem 'poi'\n\n"
coluna_x = 'total_stock_value'
coluna_y = 'bonus'
coluna_hue = 'poi'
sns.scatterplot(data=df, x=coluna_x, y=coluna_y, hue=coluna_hue, color='r')
#sns.scatterplot(data=df, x=coluna_y, y=coluna_y, hue=coluna_hue, color='b', label='Bonus')
# detalhes do plot
plt.title('Scatter Plot de poi no total em ações')
plt.xlim(0, 60000000)
plt.ylim(0, 10000000)
# mostrar
plt.show()
'''
Pessoas com bônus maior do que 5 milhões tem grande probabilidade de serem 'poi'
'''
coluna_x = 'total_stock_value'
coluna_y = 'to_messages'
coluna_hue = 'poi'
sns.scatterplot(data=df, x=coluna_x, y=coluna_y, hue=coluna_hue, color='r')
#sns.scatterplot(data=df, x=coluna_y, y=coluna_y, hue=coluna_hue, color='b', label='Bonus')
# detalhes do plot
plt.title('Scatter Plot de poi total de mensagens vs valor em ações')
plt.xlim(0, 50000000)
plt.ylim(0, 20000)
# mostrar
plt.show()
'''
Todos que detem mais de 20 milhôes em ações e receberam menos de 5000 mensagens
são 'poi'.
Quem recebe mais de 5 mil mensagem dificilmente é 'poi'.
'''
coluna_y = 'loan_advances'
coluna_x = 'long_term_incentive'
coluna_hue = 'poi'
sns.scatterplot(data=df, x=coluna_x, y=coluna_y, hue=coluna_hue, color='r')
#sns.scatterplot(data=df, x=coluna_y, y=coluna_y, hue=coluna_hue, color='b', label='Bonus')
# detalhes do plot
plt.title('Scatter Plot de poi total de mensagens vs valor em ações')
plt.xlim()
plt.ylim()
# mostrar
plt.show()
'''
gráfico mostrado devido a correlação, porém mostra sua irrelevância.
'''
'\n\ngráfico mostrado devido a correlação, porém mostra sua irrelevância.\n\n'
# essas variáveis contam com correlação relativamente alta com poi devido aos poucos valores
sns.lmplot(x="salary", y="to_messages", hue="poi", data=df);
'''
Salários acima de 1 milhão ao ano indicam forte indicio de pessoa 'poi'.
'''
"\n\nSalários acima de 1 milhão ao ano indicam forte indicio de pessoa 'poi'.\n\n"
sns.lmplot(x="to_messages", y="total_stock_value", hue="poi", data=df,
markers=["o", "x"], palette="Set1");
# tentativas de utilização de outras formas gráficas
sns.jointplot(x="salary", y="total_stock_value", data=df, kind="reg");
## utilização de outros palettes do sns
x_column = 'salary'
y_column = 'bonus'
hue_column = 'poi'
fig, ax = plt.subplots()
sns.scatterplot(data=df, x=x_column, y=y_column, color='red', ax=ax)
sns.scatterplot(data=df, x=y_column, y=x_column, color='blue', ax=ax)
sns.scatterplot(data=df, x=x_column, y=y_column, hue=hue_column, palette='pastel', ax=ax)
plt.title('Scatter Plot de salário x bônus')
plt.xlabel(x_column)
plt.ylabel(y_column)
plt.show()
'''
tentativa de melhorar a qualidade das cores do gráfico,
até esse momento imaginava que era possível colorir as subpopulações
de cor diferente, só aí percebi que eram a mesma, com 'poi' em destaque.
'''
"\n\ntentativa de melhorar a qualidade das cores do gráfico, \naté esse momento imaginava que era possível colorir as subpopulações\nde cor diferente, só aí percebi que eram a mesma, com 'poi' em destaque.\n\n"
x_column = 'salary'
y_column = 'bonus'
hue_column = 'poi'
fig, ax = plt.subplots()
sns.scatterplot(data=df, x=x_column, y=y_column, color='red', ax=ax, label='salário')
sns.scatterplot(data=df, x=y_column, y=x_column, color='blue', ax=ax, label ='bônus')
sns.scatterplot(data=df, x=x_column, y=y_column, hue=hue_column, palette='pastel', ax=ax)
plt.title('Scatter Plot bonus x salário com hue == "poi"')
plt.xlabel(x_column)
plt.ylabel(y_column)
plt.xlim (0, 4000000)
plt.ylim(0, 4000000)
plt.show()
'''
Resultados negativos também são resultados
'''
'''
PARTE IV:
'''
'\n\nPARTE IV:\n\n\n'
# poi com salário
sns.boxplot(data=df, x='poi', y='salary', showfliers=False) #para retirar whiskers
# labels
plt.xlabel('Pessoa de interesse: (0 - não / 1 - Sim )')
plt.ylabel('Salário')
plt.title('Como POI Correlaciona com salário?')
# Display the plot
plt.show()
# correlação poi/bonus
sns.boxplot(data=df, x='poi', y='bonus', showfliers=False) #para retirar whiskers
# labels
plt.xlabel('Pessoa de interesse: (0 - não / 1 - Sim )')
plt.ylabel('Bonus')
plt.title('Como POI Correlaciona com Bônus?')
# plot
plt.show()
df3 = df.copy()
df3['email_address'] = df3['email_address'].fillna(0)
df3.loc[df3['email_address'] != 0, 'email_address'] = 1
df3
## transformando e-mail em nan = 0 e existente = 1
| bonus | deferral_payments | deferred_income | director_fees | email_address | exercised_stock_options | expenses | from_messages | from_poi_to_this_person | from_this_person_to_poi | ... | other | poi | restricted_stock | restricted_stock_deferred | salary | shared_receipt_with_poi | to_messages | total_payments | total_stock_value | name | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 4175000.0 | 2869717.0 | -3081055.0 | NaN | 1 | 1729541.0 | 13868.0 | 2195.0 | 47.0 | 65.0 | ... | 152.0 | 0 | 126027.0 | -126027.0 | 201955.0 | 1407.0 | 2902.0 | 4484442.0 | 1729541.0 | ALLEN PHILLIP K |
| 1 | NaN | 178980.0 | NaN | NaN | 0 | 257817.0 | 3486.0 | NaN | NaN | NaN | ... | NaN | 0 | NaN | NaN | NaN | NaN | NaN | 182466.0 | 257817.0 | BADUM JAMES P |
| 2 | NaN | NaN | -5104.0 | NaN | 1 | 4046157.0 | 56301.0 | 29.0 | 39.0 | 0.0 | ... | 864523.0 | 0 | 1757552.0 | -560222.0 | 477.0 | 465.0 | 566.0 | 916197.0 | 5243487.0 | BANNANTINE JAMES M |
| 3 | 1200000.0 | 1295738.0 | -1386055.0 | NaN | 0 | 6680544.0 | 11200.0 | NaN | NaN | NaN | ... | 2660303.0 | 0 | 3942714.0 | NaN | 267102.0 | NaN | NaN | 5634343.0 | 10623258.0 | BAXTER JOHN C |
| 4 | 400000.0 | 260455.0 | -201641.0 | NaN | 1 | NaN | 129142.0 | NaN | NaN | NaN | ... | 69.0 | 0 | 145796.0 | -82782.0 | 239671.0 | NaN | NaN | 827696.0 | 63014.0 | BAY FRANKLIN R |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 141 | NaN | NaN | -25000.0 | 108579.0 | 0 | NaN | 1413.0 | NaN | NaN | NaN | ... | NaN | 0 | NaN | NaN | NaN | NaN | NaN | 84992.0 | NaN | WINOKUR JR. HERBERT S |
| 142 | NaN | NaN | NaN | NaN | 1 | NaN | NaN | NaN | NaN | NaN | ... | 189583.0 | 0 | NaN | NaN | NaN | NaN | NaN | 189583.0 | NaN | WODRASKA JOHN |
| 143 | NaN | NaN | NaN | NaN | 0 | 139130.0 | NaN | NaN | NaN | NaN | ... | NaN | 0 | NaN | NaN | NaN | NaN | NaN | NaN | 139130.0 | WROBEL BRUCE |
| 144 | NaN | NaN | NaN | NaN | 1 | 8308552.0 | 53947.0 | NaN | NaN | NaN | ... | 147950.0 | 1 | 3576206.0 | NaN | 158403.0 | NaN | NaN | 360300.0 | 11884758.0 | YEAGER F SCOTT |
| 145 | NaN | NaN | NaN | NaN | 0 | 192758.0 | 55097.0 | NaN | NaN | NaN | ... | NaN | 0 | NaN | NaN | NaN | NaN | NaN | 55097.0 | 192758.0 | YEAP SOON |
146 rows × 22 columns
sns.catplot(data=df3, x="poi", y="to_messages")
plt.title('Mensagem enviadas x frandadores')
plt.xlabel('Pessoa de interesse: (0 - não / 1 - Sim )')
plt.show
<function matplotlib.pyplot.show(close=None, block=None)>
sns.catplot(data=df3, x="poi", y="total_stock_value", hue='email_address')
plt.title('Ações por "poi" com ou sem e-mail')
plt.ylim(0, 20000000)
plt.xlabel('Pessoa de interesse: (0 - não / 1 - Sim )')
plt.show
'''
todos os 'poi' tem e-mail
'''
"\n\ntodos os 'poi' tem e-mail\n\n"
sns.catplot(data=df3, x="poi", y="bonus", hue='email_address')
plt.title('Ações por "poi" com ou sem e-mail')
plt.ylim(0, 100000000)
plt.xlabel('Pessoa de interesse: (0 - não / 1 - Sim )')
plt.show
'''
O detentor da maior bonificação não possui e-mail
logo, todos os bonificados acima de 5 milhões sem e-mail são 'poi'
'''
"\n\nO detentor da maior bonificação não tem e-mail\nlogo, todos os bonificados acima de 5 milhões sem e-mail são 'poi'\n\n"
sns.catplot(data=df3, x="poi", y="director_fees", hue='email_address')
plt.title('Taxa de diretoria "poi" com ou sem e-mail')
plt.ylim(0, 500000)
plt.xlabel('Pessoa de interesse: (0 - não / 1 - Sim )')
plt.show
'''
Fraudadores não pagam taxa de diretoria
'''
'''
'email_address',
'exercised_stock_options',
'expenses',
'from_messages',
'from_poi_to_this_person',
'from_this_person_to_poi',
'loan_advances',
'long_term_incentive',
'other',
'poi',
'restricted_stock',
'restricted_stock_deferred',
'salary',
'shared_receipt_with_poi',
'to_messages',
'total_payments',
'total_stock_value',
'name']
'''
"\n\n 'email_address',\n 'exercised_stock_options',\n 'expenses',\n 'from_messages',\n 'from_poi_to_this_person',\n 'from_this_person_to_poi',\n 'loan_advances',\n 'long_term_incentive',\n 'other',\n 'poi',\n 'restricted_stock',\n 'restricted_stock_deferred',\n 'salary',\n 'shared_receipt_with_poi',\n 'to_messages',\n 'total_payments',\n 'total_stock_value',\n 'name']\n "
sns.catplot(data=df3, x="poi", y="exercised_stock_options", hue='email_address')
plt.title('Exercicio de opções por "poi" com ou sem e-mail')
plt.ylim(0, 50000000)
plt.xlabel('Pessoa de interesse: (0 - não / 1 - Sim )')
plt.show
'''
Com excessão do grande chefe, exercício de opções acima de 20 milhões sempre
vem de fraudadores
'''
"\n\n 'email_address',\n '',\n 'expenses',\n 'from_messages',\n 'from_poi_to_this_person',\n 'from_this_person_to_poi',\n 'loan_advances',\n 'long_term_incentive',\n 'other',\n 'poi',\n 'restricted_stock',\n 'restricted_stock_deferred',\n 'salary',\n 'shared_receipt_with_poi',\n 'to_messages',\n 'total_payments',\n 'total_stock_value',\n 'name']\n "
sns.catplot(data=df3, x="poi", y="restricted_stock_deferred", hue='email_address')
plt.title('Ações restritas deferidas nas mãos de "poi" com ou sem e-mail')
plt.ylim(-1000000, 5000000)
plt.xlabel('Pessoa de interesse: (0 - não / 1 - Sim )')
plt.show
'''
Fraudadores não contam com ações restritas deferidas
'''
"\n\n 'salary',\n 'shared_receipt_with_poi',\n 'to_messages',\n 'total_payments',\n 'total_stock_value',\n 'name']\n "
sns.catplot(data=df3, x="poi", y="salary", hue='email_address')
plt.title('Salário e "poi" com ou sem e-mail')
plt.ylim(0, 1200000)
plt.xlabel('Pessoa de interesse: (0 - não / 1 - Sim )')
plt.show
'''
Apenas um fraudador conta com salário abaixo de 200 mil ao ano,
salário, bônus, posição de ações e numero de mensagens recebidas
são os melhores critérios para buscar ´poi
'''
'\n\nApenas um fraudador conta com salário abaixo de 200 mil ao ano, \nsalário, bônus, posição de ações e numero de mensagens recebidas\nsão os melhores critérios para buscar ´poi\n\n'
df2.name
'''
nome dos fraudadores conhecidos
'''
7 BELDEN TIMOTHY N 15 BOWEN JR RAYMOND M 20 CALGER CHRISTOPHER F 22 CAUSEY RICHARD A 26 COLWELL WESLEY 31 DELAINEY DAVID W 43 FASTOW ANDREW S 54 GLISAN JR BEN F 59 HANNON KEVIN P 65 HIRKO JOSEPH 76 KOENIG MARK E 77 KOPPER MICHAEL J 79 LAY KENNETH L 112 RICE KENNETH D 113 RIEKER PAULA H 119 SHELBY REX 122 SKILLING JEFFREY K 144 YEAGER F SCOTT Name: name, dtype: object
De maneira geral, os fraudadores recebiam bônus acima dos salários, além de receberem salários acima de 200 mil ao ano
'''
De maneira geral, os fraudadores recebiam bônus acima dos compátiveis com seus salários,
além de receberem salários acima de 200 mil ao ano, que embora muito abaixo da média de
mais de 500 mil ao ano (devido aos outliers muito expressivos), se apresenta com um bom dado
de filtragem.
De maneira geral, os individuos 'poi' dificeis de filtrar, porém com excessão de 1, todos os
outliers são 'poi' e nenhum deles pagaram as taxas de diretoria.
Embora essa análise não seja muito eficiente na categorização dos 'poi', ela pode ser
eficar em barrar as principais fraudes, que representam o maiorvolume de capital,
Não sendo irrelevante.
'''
"\n\n\nDe maneira geral, os fraudadores recebiam bônus acima dos compátiveis com seus salários, \nalém de receberem salários acima de 200 mil ao ano, que embora muito abaixo da média de\nmais de 500 mil ao ano (devido aos outliers muito expressivos), se apresenta com um bom dado\nde filtragem.\n\nDe maneira geral, os individuos 'poi' dificeis de filtrar, porém com excessão de 1, todos os\noutliers são 'poi' e nenhum deles pagaram as taxas de diretoria. \n\nEmbora essa análise não seja muito eficiente na categorização dos 'poi', ela pode ser\neficar em barrar as principais fraudes, que representam o maiorvolume de capital, \nNão sendo irrelevante.\n\n\n"
# Conversão a HTML
%%shell
jupyter nbconvert --to html /content/ATP2_TOMAZINI_ER_ModeloBasketRegressao.ipynb
[NbConvertApp] WARNING | pattern '/content/ATP2_TOMAZINI_ER_ModeloBasketRegressao.ipynb' matched no files
This application is used to convert notebook files (*.ipynb)
to various other formats.
WARNING: THE COMMANDLINE INTERFACE MAY CHANGE IN FUTURE RELEASES.
Options
=======
The options below are convenience aliases to configurable class-options,
as listed in the "Equivalent to" description-line of the aliases.
To see all configurable class-options for some <cmd>, use:
<cmd> --help-all
--debug
set log level to logging.DEBUG (maximize logging output)
Equivalent to: [--Application.log_level=10]
--show-config
Show the application's configuration (human-readable format)
Equivalent to: [--Application.show_config=True]
--show-config-json
Show the application's configuration (json format)
Equivalent to: [--Application.show_config_json=True]
--generate-config
generate default config file
Equivalent to: [--JupyterApp.generate_config=True]
-y
Answer yes to any questions instead of prompting.
Equivalent to: [--JupyterApp.answer_yes=True]
--execute
Execute the notebook prior to export.
Equivalent to: [--ExecutePreprocessor.enabled=True]
--allow-errors
Continue notebook execution even if one of the cells throws an error and include the error message in the cell output (the default behaviour is to abort conversion). This flag is only relevant if '--execute' was specified, too.
Equivalent to: [--ExecutePreprocessor.allow_errors=True]
--stdin
read a single notebook file from stdin. Write the resulting notebook with default basename 'notebook.*'
Equivalent to: [--NbConvertApp.from_stdin=True]
--stdout
Write notebook output to stdout instead of files.
Equivalent to: [--NbConvertApp.writer_class=StdoutWriter]
--inplace
Run nbconvert in place, overwriting the existing notebook (only
relevant when converting to notebook format)
Equivalent to: [--NbConvertApp.use_output_suffix=False --NbConvertApp.export_format=notebook --FilesWriter.build_directory=]
--clear-output
Clear output of current file and save in place,
overwriting the existing notebook.
Equivalent to: [--NbConvertApp.use_output_suffix=False --NbConvertApp.export_format=notebook --FilesWriter.build_directory= --ClearOutputPreprocessor.enabled=True]
--no-prompt
Exclude input and output prompts from converted document.
Equivalent to: [--TemplateExporter.exclude_input_prompt=True --TemplateExporter.exclude_output_prompt=True]
--no-input
Exclude input cells and output prompts from converted document.
This mode is ideal for generating code-free reports.
Equivalent to: [--TemplateExporter.exclude_output_prompt=True --TemplateExporter.exclude_input=True --TemplateExporter.exclude_input_prompt=True]
--allow-chromium-download
Whether to allow downloading chromium if no suitable version is found on the system.
Equivalent to: [--WebPDFExporter.allow_chromium_download=True]
--disable-chromium-sandbox
Disable chromium security sandbox when converting to PDF..
Equivalent to: [--WebPDFExporter.disable_sandbox=True]
--show-input
Shows code input. This flag is only useful for dejavu users.
Equivalent to: [--TemplateExporter.exclude_input=False]
--embed-images
Embed the images as base64 dataurls in the output. This flag is only useful for the HTML/WebPDF/Slides exports.
Equivalent to: [--HTMLExporter.embed_images=True]
--sanitize-html
Whether the HTML in Markdown cells and cell outputs should be sanitized..
Equivalent to: [--HTMLExporter.sanitize_html=True]
--log-level=<Enum>
Set the log level by value or name.
Choices: any of [0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL']
Default: 30
Equivalent to: [--Application.log_level]
--config=<Unicode>
Full path of a config file.
Default: ''
Equivalent to: [--JupyterApp.config_file]
--to=<Unicode>
The export format to be used, either one of the built-in formats
['asciidoc', 'custom', 'html', 'latex', 'markdown', 'notebook', 'pdf', 'python', 'rst', 'script', 'slides', 'webpdf']
or a dotted object name that represents the import path for an
``Exporter`` class
Default: ''
Equivalent to: [--NbConvertApp.export_format]
--template=<Unicode>
Name of the template to use
Default: ''
Equivalent to: [--TemplateExporter.template_name]
--template-file=<Unicode>
Name of the template file to use
Default: None
Equivalent to: [--TemplateExporter.template_file]
--theme=<Unicode>
Template specific theme(e.g. the name of a JupyterLab CSS theme distributed
as prebuilt extension for the lab template)
Default: 'light'
Equivalent to: [--HTMLExporter.theme]
--sanitize_html=<Bool>
Whether the HTML in Markdown cells and cell outputs should be sanitized.This
should be set to True by nbviewer or similar tools.
Default: False
Equivalent to: [--HTMLExporter.sanitize_html]
--writer=<DottedObjectName>
Writer class used to write the
results of the conversion
Default: 'FilesWriter'
Equivalent to: [--NbConvertApp.writer_class]
--post=<DottedOrNone>
PostProcessor class used to write the
results of the conversion
Default: ''
Equivalent to: [--NbConvertApp.postprocessor_class]
--output=<Unicode>
overwrite base name use for output files.
can only be used when converting one notebook at a time.
Default: ''
Equivalent to: [--NbConvertApp.output_base]
--output-dir=<Unicode>
Directory to write output(s) to. Defaults
to output to the directory of each notebook. To recover
previous default behaviour (outputting to the current
working directory) use . as the flag value.
Default: ''
Equivalent to: [--FilesWriter.build_directory]
--reveal-prefix=<Unicode>
The URL prefix for reveal.js (version 3.x).
This defaults to the reveal CDN, but can be any url pointing to a copy
of reveal.js.
For speaker notes to work, this must be a relative path to a local
copy of reveal.js: e.g., "reveal.js".
If a relative path is given, it must be a subdirectory of the
current directory (from which the server is run).
See the usage documentation
(https://nbconvert.readthedocs.io/en/latest/usage.html#reveal-js-html-slideshow)
for more details.
Default: ''
Equivalent to: [--SlidesExporter.reveal_url_prefix]
--nbformat=<Enum>
The nbformat version to write.
Use this to downgrade notebooks.
Choices: any of [1, 2, 3, 4]
Default: 4
Equivalent to: [--NotebookExporter.nbformat_version]
Examples
--------
The simplest way to use nbconvert is
> jupyter nbconvert mynotebook.ipynb --to html
Options include ['asciidoc', 'custom', 'html', 'latex', 'markdown', 'notebook', 'pdf', 'python', 'rst', 'script', 'slides', 'webpdf'].
> jupyter nbconvert --to latex mynotebook.ipynb
Both HTML and LaTeX support multiple output templates. LaTeX includes
'base', 'article' and 'report'. HTML includes 'basic', 'lab' and
'classic'. You can specify the flavor of the format used.
> jupyter nbconvert --to html --template lab mynotebook.ipynb
You can also pipe the output to stdout, rather than a file
> jupyter nbconvert mynotebook.ipynb --stdout
PDF is generated via latex
> jupyter nbconvert mynotebook.ipynb --to pdf
You can get (and serve) a Reveal.js-powered slideshow
> jupyter nbconvert myslides.ipynb --to slides --post serve
Multiple notebooks can be given at the command line in a couple of
different ways:
> jupyter nbconvert notebook*.ipynb
> jupyter nbconvert notebook1.ipynb notebook2.ipynb
or you can specify the notebooks list in a config file, containing::
c.NbConvertApp.notebooks = ["my_notebook.ipynb"]
> jupyter nbconvert --config mycfg.py
To see all available configurables, use `--help-all`.
--------------------------------------------------------------------------- CalledProcessError Traceback (most recent call last) <ipython-input-120-88dd6d6bb88b> in <cell line: 1>() ----> 1 get_ipython().run_cell_magic('shell', '', 'jupyter nbconvert --to html /content/ATP2_TOMAZINI_ER_ModeloBasketRegressao.ipynb\n') /usr/local/lib/python3.10/dist-packages/google/colab/_shell.py in run_cell_magic(self, magic_name, line, cell) 332 if line and not cell: 333 cell = ' ' --> 334 return super().run_cell_magic(magic_name, line, cell) 335 336 /usr/local/lib/python3.10/dist-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell) 2471 with self.builtin_trap: 2472 args = (magic_arg_s, cell) -> 2473 result = fn(*args, **kwargs) 2474 return result 2475 /usr/local/lib/python3.10/dist-packages/google/colab/_system_commands.py in _shell_cell_magic(args, cmd) 110 result = _run_command(cmd, clear_streamed_output=False) 111 if not parsed_args.ignore_errors: --> 112 result.check_returncode() 113 return result 114 /usr/local/lib/python3.10/dist-packages/google/colab/_system_commands.py in check_returncode(self) 135 def check_returncode(self): 136 if self.returncode: --> 137 raise subprocess.CalledProcessError( 138 returncode=self.returncode, cmd=self.args, output=self.output 139 ) CalledProcessError: Command 'jupyter nbconvert --to html /content/ATP2_TOMAZINI_ER_ModeloBasketRegressao.ipynb ' returned non-zero exit status 255.